package SevenZip;

import java.io.*;

import SevenZip.Compression.LZMA.Decoder;

public class LzmaAlone
{

	
	public static void decompress(File file, File file1)
	        throws Exception
	    {
	        File file2 = file;
	        File file3 = file1;
	        BufferedInputStream bufferedinputstream = new BufferedInputStream(new FileInputStream(file2));
	        BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(new FileOutputStream(file3));
	        byte byte0 = 5;
	        byte abyte0[] = new byte[byte0];
	        if(bufferedinputstream.read(abyte0, 0, byte0) != byte0)
	        {
	            throw new Exception("input .lzma file is too short");
	        }
	        Decoder decoder = new Decoder();
	        if(!decoder.SetDecoderProperties(abyte0))
	        {
	            throw new Exception("Incorrect stream properties");
	        }
	        long l = 0L;
	        for(int i = 0; i < 8; i++)
	        {
	            int j = bufferedinputstream.read();
	            if(j < 0)
	            {
	                throw new Exception("Can't read stream size");
	            }
	            l |= (long)j << 8 * i;
	        }

	        if(!decoder.Code(bufferedinputstream, bufferedoutputstream, l))
	        {
	            throw new Exception("Error in data stream");
	        } else
	        {
	            bufferedoutputstream.flush();
	            bufferedoutputstream.close();
	            bufferedinputstream.close();
	            return;
	        }
	    }
	
	public LzmaAlone()
	{
		
	}
}
